package com.wunong.smart.address.domain;

import com.wunong.smart.address.client.vo.AddressVO;
import com.wunong.smart.domain.platform.entify.BaseModel;
import com.wunong.smart.domain.platform.entify.User;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Objects;

/**
 * 收货人地址领域模型
 *
 * @author create by zealot.zt
 */
@Getter
@Setter
@ToString(callSuper = true)
public class UserAddressDomain extends BaseModel {

    /**
     * 用户信息
     */
    private User user;

    /**
     * 地址对象
     */
    private AddressVO addressVO;

    /**
     * 是否为默认地址
     */
    private Boolean isDefault;

    /**
     * 收货人手机号
     */
    private String mobile;

    /**
     * 收货人姓名
     */
    private String name;

    /**
     * 性别，先生，女士，未填写默认为：保密
     */
    private Integer sex;

    /**
     * 是否有效
     */
    private Boolean valid;

    /**
     * 用户地址描述
     */
    private String description;

    public static UserAddressDomain of() {
        return new UserAddressDomain();
    }

    public static UserAddressDomain ofInit() {
        UserAddressDomain domain = of();
        domain.setValid(true);
        return domain;
    }

    public Long getUserId() {
        return Objects.nonNull(user) ? user.getIdLong() : null;
    }

    /**
     * 是否有效
     *
     * @return
     */
    public boolean isValid() {
        return Boolean.TRUE.equals(valid);
    }

}
